package com.seventh.parkingrent.dao;

import com.seventh.parkingrent.controller.form.UserAuditFormForFront;
import com.seventh.parkingrent.domain.UserAudit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 用户审核记录表 Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2021-08-25
 */
public interface UserAuditMapper extends BaseMapper<UserAudit> {

    @Select(
            "<script>" +
            "select ua.*,u.username,m.manager_name " +
            "from pr_user_audit ua,pr_user u,pr_manager m " +
            "where m.manager_id=ua.manager_id and ua.user_id=u.user_id " +
            "and date(ua.row_add_time) between #{beginDate} and #{endDate} " +
            "<if test='null!=managerName'>" +
            "and m.manager_name = #{managerName} " +
            "</if>" +
            "<if test='null!=username'>" +
            "and u.username = #{username} " +
            "</if>" +
            "order by ua.row_add_time desc" +
            "</script>"
    )
    List<UserAuditFormForFront> selectUserAuditByCondition(@Param("managerName") String managerName,@Param("username") String username,@Param("beginDate") Date beginDate,@Param("endDate") Date endDate);
}
